﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace IntelliSearch.MemoryMapped.Test
{
    class Program
    {
    	static string path = AppDomain.CurrentDomain.BaseDirectory;            
        static GenericMemoryMappedArray<int> al = new GenericMemoryMappedArray<int>(100000, path); 
        static List<int> al_ = new List<int>();
		static int j=0;
		
        [Benchmark]
        public static void TestInsert_Ideal()
    	{
    		for (int i=0; i < 100000; i++)
    			al_.Add(i);
    	}

    	[Benchmark]
    	public static void TestInsert_MMF()
    	{
    		for (int i=0; i < 100000; i++)
        		al[i]=i;
    	}

    	[Benchmark]
    	public static void TestExist_Ideal()
    	{
        	for (int i=0; i < 1000; i++)
        		al_.Contains(i);
    	}

    	[Benchmark]
    	public static void TestExist_MMF()
    	{
        	for (int i=0; i < 1000; i++)
        		al.Exist(i);
    	}

    	[Benchmark]
    	public static void TestFetch_Ideal()
    	{
        	for (int i=0; i < 1000; i++)
        		j=al_[i];
    	}

    	[Benchmark]
    	public static void TestFetch_MMF()
    	{
        	for (int i=0; i < 1000; i++)
        		j=al[i];
    	}
    	
    	[Benchmark]
    	public static void TestRemoveAt_Ideal()
    	{
    		for (int i=0; i < 1000; i++)
        		al_.RemoveAt(i);
    	}
    	
    	[Benchmark]
    	public static void TestRemoveAt_MMF()
    	{
    		for (int i=0; i < 1000; i++)
        		al.RemoveAt(i);
    	}
        /*static void Main()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory;            
            var myList = new GenericMemoryMappedArray<int>(1024*1024, path); 
            using (myList)
            {
                myList[0] = 1;
                //Console.WriteLine(myList.Exist(0));
                if(myList.Exist(0))
                	Console.WriteLine(myList[0]);
                
                myList[0] = 2;
                //Console.WriteLine(myList.Exist(0));
                if(myList.Exist(0))
                	Console.WriteLine(myList[0]);

                myList.RemoveAt(0);
                if(myList.Exist(0))
                	Console.WriteLine(myList[0]);
                
                myList[1] = 3;
                //Console.WriteLine(myList.Exist(1));
                if(myList.Exist(1))
                	Console.WriteLine(myList[1]);

                Console.WriteLine(myList.Contains(2));
                Console.WriteLine(myList.Contains(3));
                
                myList.Delete(3);
                Console.WriteLine(myList.Contains(2));
                Console.WriteLine(myList.Contains(3));
                
            }
        }*/
    }
}
